<include file="public@header" />
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="{:url('Store/index')}">店铺列表</a></li>
			<if condition="$status elt 5">
			<li><a href="{:url('Store/add')}">新增店铺</a></li>
			</if>
		</ul>
		<form class="well form-inline margin-top-20" method="post" action="{:url('store/index')}">
			商铺查询：
			<input type="text" class="form-control" name="store_name" style="width: 200px;"
				   value="{:input('request.store_name')}" placeholder="填写店铺名称">
			省:
			<select class="form-control" name="provinceid" id='provinces' >
				<option value="0" >请选择</option>
				<foreach name="provinces" item="vo">
					<if condition="$vo.provinceid eq $info.provinceid">
						<option selected value="{$vo.provinceid}" >{$vo.province}</option>
						<else/>
						<option value="{$vo.provinceid}" >{$vo.province}</option>
					</if>
				</foreach>
			</select>
			市：
			<select class="form-control" name="cityid" id='city' >
				<option value="0" >请选择</option>
				<foreach name="cities" item="vo">
					<if condition="$vo.cityid eq $info.cityid">
						<option selected value="{$vo.cityid}">{$vo.city}</option>
						<else/>
						<option value="{$vo.cityid}" >{$vo.city}</option>
					</if>
				</foreach>
			</select>
			县：
			<select class="form-control" name="areaid" id='areas'>
				<option value="0" >请选择</option>
				<foreach name="areas" item="vo">
					<if condition="$vo.areaid eq $info.areasid">
						<option selected value="{$vo.areaid}" >{$vo.area}</option>
						<else/>
						<option value="{$vo.areaid}" >{$vo.area}</option>
					</if>
				</foreach>
			</select>
			<input type="submit" class="btn btn-primary" value="查询"/>
			<a class="btn btn-danger" href="{:url('store/index')}">清空</a>
		</form>
		<form action="" method="post" class="margin-top-20">
			<table class="table table-hover table-bordered">
				<thead>
					<tr>
						<th width="40">ID</th>
						<th align="left">店铺名称</th>
						<th align="left">店铺类别</th>
						<th align="left">负责人</th>
						<th align="left">地址</th>
						<th align="left">品牌</th>
						<th align="left">省市县</th>
						<th align="left">督导</th>
						<th align="left">状态</th>
						<th align="left">时间</th>
						<th align="left">店铺版本</th>
						<th width="160">操作</th>
					</tr>
				</thead>
				<tbody>
					<foreach name="list" item="vo">
					<tr>
						<td>{$vo.id}</td>
						<td>{$vo.store_name}</td>
						<td>{:get_store_type($vo['cat_store'],'cat_name')}</td>
						<td>{$vo.principal}</td>
						<td>{$vo.address}</td>
						<td>{:getbrand($vo['brandid'],'name')}</td>
						<td>{$vo.province}->{$vo.city}->{$vo.area}</td>
						<td>{:get_operator_data($vo['steer'],'user_login')}</td>
						<if condition="$vo.status eq -3">
						<td style="color: red">{$vo.status|get_kg}</td>
						<else/>
						<td>{$vo.status|get_kg}</td>
						</if>
						<td>{$vo.ctime|time_format}</td>
						<td>{$vo.version}</td>
						<td>
						<a href="{:url('Store/edit',array('id'=>$vo['id']))}">{:lang('EDIT')}</a>
						<a class="js-ajax-delete" href="{:url('Store/delete',array('id'=>$vo['id']))}">{:lang('DELETE')}</a>
						 <if condition="$vo.status eq -3">
							<a href="{:url('Store/update',array('id'=>$vo['id'],'status'=>1))}">开店</a>
						 <else/>
							 <a href="{:url('Store/update',array('id'=>$vo['id'],'status'=>-3))}">关店</a>
						 </if>
					</td>
					</tr>
					</foreach>
				</tbody>
			</table>
			<div class="pagination">{$page}</div>
		</form>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
</body>
</html>
<script>
    $('#provinces').change(function () {
        var provinces=$('#provinces option:selected').val();
        $.post("{:url('store/city')}",{provinces:provinces},function (date) {
            var con="";
            $.each(date.msg,function(k,v){
                con +='<option value='+v.cityid+' >'+v.city+'</option>'
                $('#city').html(con);
            })
        })
    })
    $('#city').change(function(){
        var city=$('#city option:selected').val();
        if(city==0)
        {
            alert("请选择市级单位");
            return false;
        }
        $.post("{:url('store/areas')}",{city:city},function (date) {
            var con="";
            $.each(date.msg,function(k,v){
                con +='<option value='+v.areaid+' >'+v.area+'</option>'
                $('#areas').html(con);
            })
        })
    })
</script>